package cn.com.coding.system.service.impl;

import cn.com.coding.common.utils.PageUtil;
import cn.com.coding.common.utils.Query;
import cn.com.coding.system.dao.GlInfoDao;
import cn.com.coding.system.domin.GlInfoEntity;
import cn.com.coding.system.service.GlInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("glInfoService")
public class GlInfoServiceImpl extends ServiceImpl<GlInfoDao, GlInfoEntity> implements GlInfoService {

    @Override
    public PageUtil queryPage(Map<String, Object> params) {
        QueryWrapper<GlInfoEntity> eq = new QueryWrapper<>();
        params.put("limit", params.get("limit").toString());
        if (params.get("page") != null) {
            params.put("page", params.get("page").toString());
        }
        if (params.get("categoryPid") != null) {
            eq.eq("gl_category_pid", params.get("categoryPid"));
        }
        eq.orderByDesc("update_time");
        IPage<GlInfoEntity> page = this.page(new Query<GlInfoEntity>().getPage(params), eq);

        return new PageUtil(page);
    }

}